package cn.donting.jme.edit.state;

import cn.donting.jme.edit.EditorState;
import com.jme3.app.Application;
import com.jme3.app.state.AbstractAppState;
import com.jme3.app.state.AppStateManager;
import com.jme3.math.Quaternion;
import com.jme3.math.Vector3f;
import com.jme3.post.SceneProcessor;
import com.jme3.profile.AppProfiler;
import com.jme3.renderer.Camera;
import com.jme3.renderer.RenderManager;
import com.jme3.renderer.ViewPort;
import com.jme3.renderer.queue.RenderQueue;
import com.jme3.texture.FrameBuffer;


/**
 * 右上角的三维坐标参考系
 * TODO://右上角的三维坐标参考系
 */
public class CoordinateViewAppState extends AbstractAppState implements SceneProcessor{

    private ViewPort coordinateViewPort;
    private Camera coordinateCamera;

    private final int coordinateCameraW = 50;
    private final int coordinateCameraH = 50;
    private RenderManager renderManager;
    private Camera editCamera;

    @Override
    public void initialize(AppStateManager stateManager, Application app) {
        super.initialize(stateManager, app);
        renderManager = app.getRenderManager();
        editCamera=EditorState.getJmeEditSceneApp().getCamera();
    }

    @Override
    public void update(float tpf) {
        //编辑器的主相机 与 coordinateCamera 旋转角度同步
        Quaternion rotation = editCamera.getRotation();
        coordinateCamera.setRotation(rotation.clone());
        //TODO:坐标轴放在 始终放在 coordinateCamera 前方固定位置
        Vector3f direction = coordinateCamera.getDirection();
    }

    @Override
    public void initialize(RenderManager rm, ViewPort vp) {

    }

    @Override
    public void reshape(ViewPort vp, int w, int h) {

    }

    @Override
    public void preFrame(float tpf) {

    }

    @Override
    public void postQueue(RenderQueue rq) {

    }

    @Override
    public void postFrame(FrameBuffer out) {

    }

    @Override
    public void setProfiler(AppProfiler profiler) {

    }
}
